C# The way to store a temporary data: Memory Cache, Redis


There's a time, I need to call the third party login API, so I try to not call that API every time I need to retrieve the information.

And there's two ways to do this, Memory Cache and Redis.
I chose Memory Cache, what I did is that I store a DataTable into the Memory Cache, like I store keys and values with hashMap.

As long as My website is on, I update the Cache if I need (member login or logout), or I just take a row out from that dataTable in the Cache and send a response with information to the client. This will save a lot of process for getting the information from the third party when the client refreshes the page, because it doesn't need to go to the third party server, I can just hand the client the information from my Memory Cache.

If the website is off for some reason, I'll just need to call the third party login api to get the information and restore it into my Memory Cache.

#C# #MemoryCache #Memory Cache #cache #Redis






你可能感興趣的文章

Web開發學習筆記02 — 等號比較運算子(Equality operators) “==” vs. “===”

Web開發學習筆記02 — 等號比較運算子(Equality operators) “==” vs. “===”

JS-[promises篇]-消耗一個promise以及串接promise 與錯誤處理

JS-[promises篇]-消耗一個promise以及串接promise 與錯誤處理

 網站部署 --AWS EC2 雲端主機 + LAMP Server + phpMyAdmin

網站部署 --AWS EC2 雲端主機 + LAMP Server + phpMyAdmin






留言討論